<template>
  <j-modal
    :title="title"
    :width="800"
    :visible="visible"
    :maskClosable="false"
    :ok-button-props="{ props: { disabled: disableSubmit } }"
    :fullscreen="true"
    @close="close"
    cancelText="关闭">
    <div style="margin:0 auto;" :class="{isCheck:isCheck}">
      <table class="table table-striped table-bordered" align="center" valign="center">
        <tr>
          <td class="column title" colspan="12">基本信息</td>
        </tr>
        <tr>
          <td class="column">计划编号</td>
          <td class="value">
            <a-input v-model="queryParam.number"
                     :disabled="disableSubmit"></a-input>
          </td>
          <!--          无-->
          <td class="column">计划年度</td>
          <td class="value">
            <a-input v-model="queryParam.planYear"
                     :disabled="disableSubmit"></a-input>
          </td>
          <td class="column">计划名称</td>
          <td class="value">
            <a-input v-model="queryParam.name"
                     :disabled="disableSubmit"></a-input>
          </td>
        </tr>
        <tr>
          <td class="column">计划类别</td>
          <td class="value">
            <a-input v-model="queryParam.type_dictText"
                     :disabled="disableSubmit"></a-input>
          </td>
          <td class="column">审计单位</td>
          <td class="value">
            <a-input v-model="queryParam.remidText"
                     :disabled="disableSubmit"></a-input>
          </td>
          <td class="column">计划负责人</td>
          <td class="value">
            <a-input v-model="queryParam.principalText"
                     :disabled="disableSubmit"></a-input>
          </td>
        </tr>
        <tr>
          <td class="column">年度审计工作目标</td>
          <td class="value" colspan="12" style="height: 100px">
            <a-textarea v-model="queryParam.aims" style="height: 100%"
                        :disabled="disableSubmit"></a-textarea>
          </td>
        </tr>
        <tr>
          <td class="column title" colspan="12">审计项目计划明细
          </td>
        </tr>
        <tr>
          <td class="value" colspan="12" style='padding:0'>
            <a-table
              class="edit-list"
              ref="table"
              size="middle"
              bordered
              style="width:200vh"
              :columns="columns"
              :dataSource="dataSource"
              :pagination="ipagination"
              :scroll="{ y: 350 }">
            </a-table>
          </td>
        </tr>
      </table>
      <a-button style="margin-top:10px;padding:0 10px;float: right" type="primary" icon="download" @click="exportList()">
        导出Excel
      </a-button>
      <!--      <a-button style="padding:0 15px;position: relative;left: 50%;top:15px" type="primary" icon="download"-->
      <!--                @click="exportList()">导出-->
      <!--      </a-button>-->
    </div>
  </j-modal>
</template>
<script>
  import {httpAction, getAction} from '@/api/manage'
  import columns from "./columns"

  export default {
    name: 'SysPositionModal',
    components: {},
    data() {
      return {
        columns: columns(this),
        dataSource: [],
        ipagination: {
          current: 1,
          pageSize: 10,
          showTotal: (total, range) => {
            return range[0] + "-" + range[1] + " 共" + total + "条"
          },
          onChange: (pageNumber) => {
            this.onChange(pageNumber)
          },
          showQuickJumper: true,
          total: 0
        },
        disableSubmit: false,
        title: '',
        visible: false,
        isCheck: false,
        model: {},
        url: {
          get: '/sjzyzhgl/sjPlanInfo/planInfoList',
          list: '/sjzyzhgl/sjPlanProjectInfo/projectInfolist',
          exportList: '/sjzyzhgl/sjPlanInfo/exportXlsByTemplate'
        },
        organShow: true,
        queryParam: {
          unitname: '',
          unit: ''
        }
      }
    },
    created() {
    },
    methods: {
      check(record) {
        this.model = Object.assign({}, record)
        this.visible = true
        this.httpRequest()
        this.list()
      },
      httpRequest() {
        getAction(this.url.get, {id: this.model.id}).then((res) => {
          if (res.success && res.result.records.length > 0) {
            this.queryParam = res.result.records[0]
          } else {
            console.log(res)
          }
        }).finally(() => {
        })
      },
      list() {
        getAction(this.url.list, {
          proId: this.model.id,
          pageSize: this.ipagination.pageSize,
          pageNo: this.ipagination.current
        }).then((res) => {
          if (res.success && res.result) {
            this.dataSource = res.result.records
            this.ipagination.total = res.result.total;
          } else {
            this.ipagination.total = 0;
          }
        })
      },
      onChange(pageNumber) {
        this.ipagination.current = pageNumber
        this.list()
      },
      exportList() {
        getAction(this.url.exportList, {id: this.model.id}).then((res) => {
          if (res.success && res.result) {
            this.$message.success('正在下载，请稍等！')
            let url = `${window._CONFIG['domianURL']}/sys/common/static${res.result}`
            window.open(url, '_blank')
          } else {
          }
        }).finally(() => {
        })
      },
      close(isSubmit) {
        if (isSubmit) {
        } else {
          this.visible = false
        }
      },
    }
  }
</script>

<style lang="less" scoped>
  @import '../../css/checkAndEdit.less';
</style>
